#include<iostream>
#include<thread>
#include<future>

int func020() {
	int index = 0;
	for (int i = 0; i < 1000; i++)
	{
		index++;
		
	}
	std::this_thread::sleep_for(std::chrono::seconds(5));
	return index;
}
int func0200() {
	int index = 1000;
	for (int i = 0; i < 1000; i++)
	{
		index++;
	}
	std::this_thread::sleep_for(std::chrono::seconds(5));
	return index;
}

int main020() {
	std::packaged_task<int()> task(func020);
	std::future<int> futureResult = task.get_future();
	std::thread t1(std::move(task));
	t1.join();

	std::packaged_task<int()> task2(func0200);
	std::future<int> futureResult2 = task2.get_future();
	std::thread t2(std::move(task2));
	t2.join();

	int val1 = futureResult.get();
	int val2 = futureResult2.get();
	std::cout << val1 << std::endl;
	std::cout << val2 << std::endl;
	int sums = val1 + val2;
	std::cout << sums << std::endl;

	return 0;
}